using Dew.Math;
using Dew.Math.Editors;
using Dew.Math.Units;
using Dew.Signal;
using Dew.Signal.Units;
using Dew.Math.Tee;
using Dew.Signal.Tee;
private void button1_Click(
object sender, EventArgs e)
{
Vector z =
new Vector(0);
Vector p =
new Vector(0);
Vector num =
new Vector(0);
Vector den =
new Vector(0);
Vector Response =
new Vector(0);
Vector b =
new Vector(0);
Vector c =
new Vector(0);
double k,Wc,d;
Matrix A =
new Matrix(0,0);
double FS = 2;
int Order = 5;
//design a fifth order filter.
IIRFilters.EllipticAnalog(Order,0.2,40,z,p,
out k);
//design analog protype
//passband ripple 0.2dB, stopband attenuation 40dB
LinearSystems.Bilinear(z,p,
ref k,FS,
true);
//Sampling frequency = 2
Wc = 0.6;
//request a cutoff at 0.6 Hz
LinearSystems.LowpassToLowpassZ(z,p,
ref k,Wc, LinearSystems.BilinearUnwarp(1,FS));
//frequency transformation in z-domain
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
SignalUtils.FrequencyResponse(num, den, Response, 64,
false, TSignalWindowType.wtRectangular, 0);
//zero padding set to 64
MtxVecTee.DrawIt(Response, "Design method 0",
false);
//Alternative 1:
IIRFilters.EllipticAnalog(Order,0.2,40,z,p,
out k);
//design analog protype
LinearSystems.Bilinear(z,p,
ref k,FS,
true);
//Sampling frequency = 2
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
Wc = 0.6;
//request a cutoff at 0.6 Hz
LinearSystems.LowpassToLowpassZ(num,den,Wc,LinearSystems.BilinearUnwarp(1,FS));
//frequency transformation in z-domain
SignalUtils.FrequencyResponse(num, den, Response, 64,
false, TSignalWindowType.wtRectangular, 0);
//zero padding set to 64
MtxVecTee.DrawIt(Response, "Design method 1",
false);
//Alternative 2:
IIRFilters.EllipticAnalog(Order,0.2,40,z,p,
out k);
//design analog protype
Wc = LinearSystems.BilinearPrewarp(0.6,FS);
//request a cutoff at 0.6 Hz
LinearSystems.LowpassToLowpass(z,p,
ref k,Wc);
//frequency transformation in s-domain
LinearSystems.Bilinear(z,p,
ref k, FS,
true);
//Sampling frequency = 2
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
SignalUtils.FrequencyResponse(num, den, Response, 64,
false, TSignalWindowType.wtRectangular, 0);
//zero padding set to 64
MtxVecTee.DrawIt(Response, "Design method 2",
false);
//Alternative 3:
IIRFilters.EllipticAnalog(Order,0.2,40,z,p,
out k);
//design analog protype
LinearSystems.ZeroPoleToStateSpace(A,b,c,
out d,z,p,k);
Wc = LinearSystems.BilinearPrewarp(0.6,FS);
//request a cutoff at 0.6 Hz
LinearSystems.LowpassToLowpass(A,b,c,
ref d,Wc);
//frequency transformation in s-domain
LinearSystems.Bilinear(A,b,c,
ref d,2);
LinearSystems.StateSpaceToZeroPole(z,p,
out k,A,b,c,d);
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
SignalUtils.FrequencyResponse(num,den,Response,64,
false,TSignalWindowType.wtRectangular,0);
//zero padding set to 64
MtxVecTee.DrawIt(Response,"Design method 3",
false);
}